package book;

/**
 * @ClassDescription:书
 * @JdkVersion: 1.8
 * @Author: 李白
 * @Created: 2024/7/23 22:00
 */
public class Book {
    //所有成员采用private修饰，是为了保护数据
    private String name;
    private String author;
    private int price;
    private String type;
    private boolean isborrowed;

    public Book(String name, String author, int price, String type, boolean isBorrowed) {//构造方法
        this.name = name;
        this.author = author;
        this.price = price;
        this.type = type;
        this.isborrowed = isBorrowed;
    }

    public Book(String name, String author, int price, String type) {//通过构造方法给变量赋值
        this.name = name;
        this.author = author;
        this.price = price;
        this.type = type;
    }
    //toString类属于object类，而String类作为一个类被导入这个book类中，所以重写是有依据的
    //这是因为 String 是 Java 标准库的一部分，并且所有的 Java 类都隐式地继承自 java.lang.Object，
    //而 String 类也是 java.lang 包的一部分。java.lang 包是 Java 的核心包，默认在所有 Java 程序中被导入
    @Override
    public String toString() {//打印用的
        return "Book{" +
                "name='" + name + '\'' +
                ", authon='" + author + '\'' +
                ", price=" + price +
                ", type='" + type + '\'' +
                ((isborrowed == true)?",已经借出":",未借出") +
                '}';
    }
    //以下的get和set方法，是为了在后续的增删查改中方便直接获取和修改书的各种属性

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAuthon() {
        return author;
    }

    public void setAuthon(String authon) {
        this.author = authon;
    }

    public int getPrice() {
        return price;
    }

    public void setPrice(int price) {
        this.price = price;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public boolean isIsborrowed() {
        return isborrowed;
    }

    public void setIsborrowed(boolean isborrowed) {
        this.isborrowed = isborrowed;
    }
}
